package com.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.ProductBean;
import com.project.mapper.IProductMapper;
import com.project.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @RequestMapping("findByItem")
    public IPage<ProductBean> findByItem(Integer pageNO, String name, Integer startNum, Integer endNum, String salePrice, String type) {
        return productService.findByItem(pageNO, name, startNum, endNum, salePrice, type);
    }

    @RequestMapping("findById")
    public ProductBean findById(String id) {
        return productService.findById(id);
    }

    @RequestMapping("update")
    public String updateSalePrice(String id, Integer buyMoney) {
        productService.updateSalePrice(id, buyMoney);
        return "ok";
    }

    @RequestMapping("findBySaleCar")
    public IPage<ProductBean> findBySaleCar(Integer pageNO, String name, String type) {
        return productService.findBySaleCar(pageNO, name, type);
    }

    @RequestMapping("findType")
    public List<String> findType() {
        return productService.findAllType();
    }
}
